//
//  RLParaOptimize.m
//  MacStockApp
//
//  Created by Andy MacPro on 12/8/14.
//
//

#import "RLParaOptimize.h"
#import "GBCalculationMethod_commonIndicator.h"
#import "GBCalculationMethod_selfIndicator.h"
#import "GBall.h"

@implementation RLParaOptimize

//所有最佳化參數的詳細字典
+(NSMutableDictionary *)Para_Optimize_method_property{

    NSMutableDictionary *cmp=[[[NSMutableDictionary alloc] init] autorelease];
   
    //功能步驟：最佳化視窗選項增加 功能步驟: 1.初始化字典增加    
    
    //Para_Optimize_calculates_array_LF
    {
        NSMutableDictionary *cmp_sub=[[[NSMutableDictionary alloc] init] autorelease];
        [cmp setObject:cmp_sub  forKey:Para_Optimize_calculates_array_LF];
        
        
        //是否隱藏參數欄位
        [cmp_sub setObject:[NSNumber numberWithBool:NO] forKey:Para_title_isHidden_1];
        [cmp_sub setObject:[NSNumber numberWithBool:NO] forKey:Para_title_isHidden_2];
        [cmp_sub setObject:[NSNumber numberWithBool:NO] forKey:Para_title_isHidden_3];
        [cmp_sub setObject:[NSNumber numberWithBool:NO] forKey:Para_title_isHidden_4];
        [cmp_sub setObject:[NSNumber numberWithBool:YES] forKey:Para_title_isHidden_5];
        
        //顯示參數欄位
        [cmp_sub setObject:@"買進 比例:" forKey:Para_title_1];
        [cmp_sub setObject:@"買進 期數:" forKey:Para_title_2];
        [cmp_sub setObject:@"賣出 比例:" forKey:Para_title_3];
        [cmp_sub setObject:@"賣出 期數:" forKey:Para_title_4];
        [cmp_sub setObject:@"para_title_ma_5" forKey:Para_title_5];
        
        //初始值 開始
        [cmp_sub setObject:[NSNumber numberWithFloat:0.1] forKey:Para_Default_start_1];
        [cmp_sub setObject:[NSNumber numberWithFloat:10 ] forKey:Para_Default_start_2];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.1] forKey:Para_Default_start_3];
        [cmp_sub setObject:[NSNumber numberWithFloat:10 ] forKey:Para_Default_start_4];
        [cmp_sub setObject:[NSNumber numberWithFloat:0  ] forKey:Para_Default_start_5];
       
        //初始值 結束
        [cmp_sub setObject:[NSNumber numberWithFloat:0.3] forKey:Para_Default_end_1];
        [cmp_sub setObject:[NSNumber numberWithFloat:30 ] forKey:Para_Default_end_2];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.3] forKey:Para_Default_end_3];
        [cmp_sub setObject:[NSNumber numberWithFloat:30 ] forKey:Para_Default_end_4];
        [cmp_sub setObject:[NSNumber numberWithFloat:0  ] forKey:Para_Default_end_5];
        
        //初始值 step 如果是空白用不到的step值 必須設為1 很重要 不可以設為0
        [cmp_sub setObject:[NSNumber numberWithFloat:0.05] forKey:Para_Default_step_1];
        [cmp_sub setObject:[NSNumber numberWithFloat:5 ] forKey:Para_Default_step_2];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.05] forKey:Para_Default_step_3];
        [cmp_sub setObject:[NSNumber numberWithFloat:5 ] forKey:Para_Default_step_4];
        [cmp_sub setObject:[NSNumber numberWithFloat:1  ] forKey:Para_Default_step_5];
        
        //停損機制
        [cmp_sub setObject:[NSNumber numberWithBool:YES] forKey:Para_Optimize_isUse_Stop];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.15] forKey:Para_Optimize_Stop_ratio];
        
        //產生加碼上限參數
        [cmp_sub setObject:[NSNumber numberWithBool:NO] forKey:Para_Optimize_isCreate_Add_Limit];
        
        
        
        
        //交易成本
        [cmp_sub setObject:[NSNumber numberWithFloat:0.0015] forKey:Para_Optimize_long_cost];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.0015] forKey:Para_Optimize_short_cost];
       
        //最佳化結果比較準則
        [cmp_sub setObject:[NSNumber numberWithInt:0] forKey:Para_Optimize_compare_method];
        
        //最佳化計算要用幾個執行緒來計算
        [cmp_sub setObject:[NSNumber numberWithInt:4] forKey:Para_Optimize_que_number];
        
    }
    
    //Para_Optimize_calculates_array_MESA
    {
        NSMutableDictionary *cmp_sub=[[[NSMutableDictionary alloc] init] autorelease];
        [cmp setObject:cmp_sub  forKey:Para_Optimize_calculates_array_MESA];
        
        
        //是否隱藏參數欄位
        [cmp_sub setObject:[NSNumber numberWithBool:NO] forKey:Para_title_isHidden_1];
        [cmp_sub setObject:[NSNumber numberWithBool:NO] forKey:Para_title_isHidden_2];
        [cmp_sub setObject:[NSNumber numberWithBool:YES] forKey:Para_title_isHidden_3];
        [cmp_sub setObject:[NSNumber numberWithBool:YES] forKey:Para_title_isHidden_4];
        [cmp_sub setObject:[NSNumber numberWithBool:YES] forKey:Para_title_isHidden_5];
        
        //顯示參數欄位
        [cmp_sub setObject:@"Slow Limit:" forKey:Para_title_1];
        [cmp_sub setObject:@"Fast Limit:" forKey:Para_title_2];
        [cmp_sub setObject:@"para_title_ma_3" forKey:Para_title_3];
        [cmp_sub setObject:@"para_title_ma_4" forKey:Para_title_4];
        [cmp_sub setObject:@"para_title_ma_5" forKey:Para_title_5];
        
        //初始值 開始
        [cmp_sub setObject:[NSNumber numberWithFloat:0.2  ] forKey:Para_Default_start_1];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.01 ] forKey:Para_Default_start_2];
        [cmp_sub setObject:[NSNumber numberWithFloat:0    ] forKey:Para_Default_start_3];
        [cmp_sub setObject:[NSNumber numberWithFloat:0    ] forKey:Para_Default_start_4];
        [cmp_sub setObject:[NSNumber numberWithFloat:0    ] forKey:Para_Default_start_5];
        
        //初始值 結束
        [cmp_sub setObject:[NSNumber numberWithFloat:0.6  ] forKey:Para_Default_end_1];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.3  ] forKey:Para_Default_end_2];
        [cmp_sub setObject:[NSNumber numberWithFloat:0    ] forKey:Para_Default_end_3];
        [cmp_sub setObject:[NSNumber numberWithFloat:0    ] forKey:Para_Default_end_4];
        [cmp_sub setObject:[NSNumber numberWithFloat:0    ] forKey:Para_Default_end_5];
        
        //初始值 step 如果是空白用不到的step值 必須設為1 很重要 不可以設為0
        [cmp_sub setObject:[NSNumber numberWithFloat:0.02 ] forKey:Para_Default_step_1];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.02 ] forKey:Para_Default_step_2];
        [cmp_sub setObject:[NSNumber numberWithFloat:1    ] forKey:Para_Default_step_3];
        [cmp_sub setObject:[NSNumber numberWithFloat:1    ] forKey:Para_Default_step_4];
        [cmp_sub setObject:[NSNumber numberWithFloat:1    ] forKey:Para_Default_step_5];
        
        //停損機制
        [cmp_sub setObject:[NSNumber numberWithBool:YES] forKey:Para_Optimize_isUse_Stop];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.15] forKey:Para_Optimize_Stop_ratio];
        
        //產生加碼上限參數
        [cmp_sub setObject:[NSNumber numberWithBool:NO] forKey:Para_Optimize_isCreate_Add_Limit];
        
        
        
        //交易成本
        [cmp_sub setObject:[NSNumber numberWithFloat:0.0015] forKey:Para_Optimize_long_cost];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.0015] forKey:Para_Optimize_short_cost];
        
        //最佳化結果比較準則
        [cmp_sub setObject:[NSNumber numberWithInt:0] forKey:Para_Optimize_compare_method];
        
        //最佳化計算要用幾個執行緒來計算
        [cmp_sub setObject:[NSNumber numberWithInt:4] forKey:Para_Optimize_que_number];
    }
    
    //Para_Optimize_calculates_array_LFMESA
    {
        NSMutableDictionary *cmp_sub=[[[NSMutableDictionary alloc] init] autorelease];
        [cmp setObject:cmp_sub  forKey:Para_Optimize_calculates_array_LFMESA];
        
        
        //是否隱藏參數欄位
        [cmp_sub setObject:[NSNumber numberWithBool:NO] forKey:Para_title_isHidden_1];
        [cmp_sub setObject:[NSNumber numberWithBool:NO] forKey:Para_title_isHidden_2];
        [cmp_sub setObject:[NSNumber numberWithBool:NO] forKey:Para_title_isHidden_3];
        [cmp_sub setObject:[NSNumber numberWithBool:NO] forKey:Para_title_isHidden_4];
        [cmp_sub setObject:[NSNumber numberWithBool:YES] forKey:Para_title_isHidden_5];
        
        //顯示參數欄位
        [cmp_sub setObject:@"買進 比例:" forKey:Para_title_1];
        [cmp_sub setObject:@"賣出 比例:" forKey:Para_title_2];
        [cmp_sub setObject:@"週期比例:"  forKey:Para_title_3];
        [cmp_sub setObject:@"做多加碼上限:" forKey:Para_title_4];
        [cmp_sub setObject:@"para_title_ma_5:" forKey:Para_title_5];
        
        //初始值 開始
        [cmp_sub setObject:[NSNumber numberWithFloat:0.1] forKey:Para_Default_start_1];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.1 ] forKey:Para_Default_start_2];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.5] forKey:Para_Default_start_3];
        [cmp_sub setObject:[NSNumber numberWithFloat:1 ] forKey:Para_Default_start_4];
        [cmp_sub setObject:[NSNumber numberWithFloat:0  ] forKey:Para_Default_start_5];
        
        //初始值 結束
        [cmp_sub setObject:[NSNumber numberWithFloat:1.0] forKey:Para_Default_end_1];
        [cmp_sub setObject:[NSNumber numberWithFloat:1.0 ] forKey:Para_Default_end_2];
        [cmp_sub setObject:[NSNumber numberWithFloat:1.5] forKey:Para_Default_end_3];
        [cmp_sub setObject:[NSNumber numberWithFloat:4 ] forKey:Para_Default_end_4];
        [cmp_sub setObject:[NSNumber numberWithFloat:0  ] forKey:Para_Default_end_5];
        
        //初始值 step 如果是空白用不到的step值 必須設為1 很重要 不可以設為0
        [cmp_sub setObject:[NSNumber numberWithFloat:0.1] forKey:Para_Default_step_1];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.1 ] forKey:Para_Default_step_2];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.20] forKey:Para_Default_step_3];
        [cmp_sub setObject:[NSNumber numberWithFloat:1.0 ] forKey:Para_Default_step_4];
        [cmp_sub setObject:[NSNumber numberWithFloat:1.0  ] forKey:Para_Default_step_5];
        
        //停損機制
        [cmp_sub setObject:[NSNumber numberWithBool:YES] forKey:Para_Optimize_isUse_Stop];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.15] forKey:Para_Optimize_Stop_ratio];
        
        //產生加碼上限參數
        [cmp_sub setObject:[NSNumber numberWithBool:YES] forKey:Para_Optimize_isCreate_Add_Limit];
        
        
        //交易成本
        [cmp_sub setObject:[NSNumber numberWithFloat:0.0015] forKey:Para_Optimize_long_cost];
        [cmp_sub setObject:[NSNumber numberWithFloat:0.0015] forKey:Para_Optimize_short_cost];
        
        //最佳化結果比較準則
        [cmp_sub setObject:[NSNumber numberWithInt:0] forKey:Para_Optimize_compare_method];
        
        //最佳化計算要用幾個執行緒來計算
        [cmp_sub setObject:[NSNumber numberWithInt:4] forKey:Para_Optimize_que_number];
        
    }
    
    return cmp;
    

}

//最佳化參數的方法
+(NSArray *)Para_Optimize_method_array{
    
    NSArray *tempa=[NSArray arrayWithObjects:Para_Optimize_calculates_array_LF,Para_Optimize_calculates_array_MESA,Para_Optimize_calculates_array_LFMESA, nil];
    
    
    return tempa;
}
@end
